import Vue from 'vue';
import Vuex from 'vuex'
import {_API} from '@/assets/api/http.js'
Vue.use(Vuex);
const types = {

    GET_USERS_DETAIL: 'GET_USERS_DETAIL',

}

export default new Vuex.Store({
    state: {
        usersDetail: {},
    },
    mutations: {
        [types.GET_USERS_DETAIL](state, detail) {
            state.usersDetail = detail
        },
    },
    actions: {
        // 注册用户详情
        GetUsersDetail({ commit }, params) {
            console.log("params",params)
            return new Promise((resolve, reject) => {
                    console.log("_API",)
                
                    _API.userMember(params).then(res => {
                    if (res.code === 200 && res.data) {
                        commit('GET_USERS_DETAIL', res.data)
                        resolve(res.result)
                    } else {
                        commit('GET_USERS_DETAIL', {})
                        resolve()
                    }
                }).catch(err => {
                    reject()
                })
            })
        },
    },
})